package lp.xian.materials.service.impl;

import java.util.List;

import lp.xian.materials.vo.QualityRawVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import lp.xian.materials.mapper.QualityRawMapper;
import lp.xian.materials.domain.QualityRaw;
import lp.xian.materials.service.IQualityRawService;

/**
 * 原料质检Service业务层处理
 *
 * @author ruoyi
 * @date 2023-08-15
 */
@Service
public class QualityRawServiceImpl implements IQualityRawService
{
    @Autowired
    private QualityRawMapper qualityRawMapper;

    /**
     * 查询原料质检
     *
     * @param qualityRawId 原料质检主键
     * @return 原料质检
     */
    @Override
    public QualityRaw selectQualityRawByQualityRawId(Integer qualityRawId)
    {
        return qualityRawMapper.selectQualityRawByQualityRawId(qualityRawId);
    }

    /**
     * 查询原料质检列表
     *
     * @param qualityRaw 原料质检
     * @return 原料质检
     */
    @Override
    public List<QualityRaw> selectQualityRawList(QualityRaw qualityRaw)
    {
        return qualityRawMapper.selectQualityRawList(qualityRaw);
    }

    /**
     * 新增原料质检
     *
     * @param qualityRaw 原料质检
     * @return 结果
     */
    @Override
    public int insertQualityRaw(QualityRaw qualityRaw)
    {
        return qualityRawMapper.insertQualityRaw(qualityRaw);
    }

    /**
     * 修改原料质检
     *
     * @param qualityRawvo 原料质检
     * @return 结果
     */
    @Override
    public int updateQualityRaw(QualityRawVo qualityRawvo)
    {
        QualityRaw qualityRaw=new QualityRaw();
        if(qualityRawvo.getName()==null){
            qualityRaw.setQualityRawId(qualityRawvo.getQualityRawId());
            qualityRaw.setQualityRawNum(qualityRawvo.getQualityRawNum());
            qualityRaw.setQualityUnqualifiedNum(qualityRawvo.getQualityUnqualifiedNum());
            qualityRaw.setQualityQualifiedSex(qualityRawvo.getQualityQualifiedSex());
        }
       else if (qualityRawvo.getName().equals("qualityAppearance")){
            qualityRaw.setQualityRawId(qualityRawvo.getQualityRawId());
            qualityRaw.setQualityAppearance(1);
        }
        else if (qualityRawvo.getName().equals("qualityDimensiona")){
            qualityRaw.setQualityRawId(qualityRawvo.getQualityRawId());
            qualityRaw.setQualityDimensiona(1);
        }
        else if (qualityRawvo.getName().equals("qualityStrength")){
            qualityRaw.setQualityRawId(qualityRawvo.getQualityRawId());
            qualityRaw.setQualityStrength(1);
        }
        else if (qualityRawvo.getName().equals("qualityFabric")){
            qualityRaw.setQualityRawId(qualityRawvo.getQualityRawId());
            qualityRaw.setQualityFabric(1);
        }
        else if (qualityRawvo.getName().equals("qualityChemical")){
            qualityRaw.setQualityRawId(qualityRawvo.getQualityRawId());
            qualityRaw.setQualityChemical(1);
        }
        else if (qualityRawvo.getName().equals("qualityComponent")){
            qualityRaw.setQualityRawId(qualityRawvo.getQualityRawId());
            qualityRaw.setQualityComponent(1);
        }else {
           return 1;
        }
        return qualityRawMapper.updateQualityRaw(qualityRaw);
    }

    /**
     * 批量删除原料质检
     *
     * @param qualityRawIds 需要删除的原料质检主键
     * @return 结果
     */
    @Override
    public int deleteQualityRawByQualityRawIds(Integer[] qualityRawIds)
    {
        return qualityRawMapper.deleteQualityRawByQualityRawIds(qualityRawIds);
    }

    /**
     * 删除原料质检信息
     *
     * @param qualityRawId 原料质检主键
     * @return 结果
     */
    @Override
    public int deleteQualityRawByQualityRawId(Integer qualityRawId)
    {
        return qualityRawMapper.deleteQualityRawByQualityRawId(qualityRawId);
    }
}
